# -*- coding: utf-8 -*-
# ----------------------------
# @Time    : 2022/6/18 4:28 PM
# @Author  : changqingai
# @FileName: tf_unique_gather.py
# ----------------------------

import tensorflow as tf

# ******* unique ***********sample_num = 5
a = tf.constant([4, 2, 2, 4, 3, 1])
b = tf.unique(a)
print("b:", b)
print("b.idx:", b.idx)
print("b.y:", b.y)

# tf.gather
c = tf.gather(b.y, b.idx)
print("c:", c)
d = tf.reduce_sum(tf.cast(tf.equal(c, a), tf.int32))
print("d:", d)
print("a.shape:", a)
